package cs340.stormtroopers.junitTests.phase4WhiteBox;

import junit.framework.TestCase;
import cs340.stormtroopers.hypeerweb.HyPeerWeb;
import cs340.stormtroopers.hypeerweb.Node;

/**
 * White box tests on HyPeerWeb class.
 * Does internal boundary value analysis
 * @author Andy Morrow
 *
 */
public class HyPeerWebTest extends TestCase
{
	// the internal boundary is in the addNodeToHyPeerWeb method
	// the boundary value is 0
	// can't test with -1
	// so we'll test with 0 and 1 and 2
	public void testInternalBoundaries()
	{
		HyPeerWeb hw = HyPeerWeb.getSingleton();
		hw.clear();
		
		// try with 0 nodes
		Node node = new Node(0);
		hw.addToHyPeerWeb(node, null);
		assertTrue(hw.size() == 1);
		assertTrue(node.getWebIdValue() == 0);
		
		// now try with one node in the hw
		Node node1 = new Node(0);
		hw.addToHyPeerWeb(node1, null);
		assertTrue(hw.size() == 2);
		assertTrue(node1.getWebIdValue() == 1);
		
		// now try with two
		Node node2 = new Node(0);
		hw.addToHyPeerWeb(node2, null);
		assertTrue(hw.size() == 3);
		assertTrue(node2.getWebIdValue() == 2);
	}
}
